package cn.edu.bjfu.mybatisdemo.controller;

import cn.edu.bjfu.mybatisdemo.dao.TemperatureDao;
import cn.edu.bjfu.mybatisdemo.entity.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;

@RestController
public class TestController {

    @Autowired
    private TemperatureDao temperatureDao;

    @GetMapping("/hello")
    public String doSomeThing() {
        Random random = new Random();
        Test test;
        List<Test> tests = new ArrayList<>(100);
        for (int i = 0; i < 1000; i++) {
            test = new Test();
            test.setName("index" + random.nextInt());
            // test1赋值
            tests.add(test);
        }

        temperatureDao.insertBatch(tests);
        System.gc();
        return "hello";
    }
}
